cmake_minimum_required(VERSION 3.0.2)
project(commons)

find_package(catkin REQUIRED COMPONENTS
  roscpp
)

catkin_package(
 INCLUDE_DIRS include
 LIBRARIES commons
 CATKIN_DEPENDS roscpp
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

find_package(OpenCV 4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
MESSAGE(${OpenCV_INCLUDE_DIRS})

add_library(
  ${PROJECT_NAME}
  src/ini.c
  src/INIReader.cpp
  src/libar8020.c
  src/x264_encoder.cc 
  # src/h264decoder.cc src/h264encoder.cc
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} x264)
# target_link_libraries(${PROJECT_NAME} avformat avdevice avcodec avutil avfilter postproc swresample swscale)

install(TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

# add_executable(test_x264 tests/test_x264.cc)
# target_link_libraries(test_x264 ${PROJECT_NAME})

# add_executable(test_libar8020 tests/test_libar8020.cc)
# target_link_libraries(test_libar8020 ${PROJECT_NAME})

# add_executable(test_h264 tests/test_h264.cc)
# target_link_libraries(test_h264 ${PROJECT_NAME})
